function [hit, turn, shipPos, bombedPos] = game(timeLag, ship, bomber, bombRadius)

shipPos = [0,0];    % [x,y] also store all previous positions of the ship
shipVector = [0,0]; % Euclidian vector: stores only the current velocity and direction
hit = false;        %true if the ship is hit, false if not
exploded = false;   %true if the bomb exploded
dropped = [];       %dropped = [droppedTime, droppedX, droppedY], if droppedTime=0 the bomb explodes at the droppedPlace
turn = 0;           %keep track of how many turns the game takes
observeTime = 500;  %number of turn the bomber observes

while(~exploded)
    turn = turn+1;
    if(~isempty(dropped)) % if the bomb has been dropped
        % decrease the droppedTime by 1
        dropped(1) = dropped(1)-1;
        
        %check if the bomb has exploded and handle it
        if(dropped(1) == 0)
            if( (shipPos(1,1)-dropped(2))^2 + (shipPos(1,2)-dropped(3))^2 < bombRadius*bombRadius)
                hit = true;
            end
            exploded = true;
        end
        dropPos = Inf;
    elseif(turn == observeTime) %If the bomb has not been dropped, determine the new bombing position
        if(bomber==1)   %unweighted bomber
            dropPos = bomberu(shipPos',timeLag);
        elseif(bomber==2) %weighted bomber
            dropPos = bomberw(shipPos',timeLag);
        elseif(bomber==3) %markov bomber
            dropPos = bomberm(shipPos',timeLag);
        else
            'No such bomber exists!'
        end
    else
        dropPos = Inf;
    end
    
    if(dropPos ~= Inf)
        dropped = [timeLag, dropPos];
        bombedPos = dropPos;
    end
    
    if(ship==1) %shipSimple
        shipVector = shipSimple(shipVector,shipPos);
    elseif(ship==2) %shipMarkov
        shipVector = shipMarkov(shipVector);        
    elseif(ship==3) %shipSin
        shipVector = shipSin(shipVector);        
    elseif(ship==4) %shipCurve
        shipVector = shipCurve(shipVector);        
    else
        'No such ship exists!'
    end
    
    newShipPos = shipPos(1,:) + shipVector;
    shipPos = [newShipPos(1), newShipPos(2); shipPos];
end
